#ifndef SOLUTION_H_
#define SOLUTION_H_
#include <vector>
#include <string>

using namespace std;
class Solution {
public:
    string longestCommonPrefix(vector<string> &strs) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
		if(strs.empty())
			return "";

		if(strs.size() == 1)
			return strs[0];


        size_t idx = 0;
		bool found = false;
		while(!found)
		{
			if(idx >= strs[0].size())
			{
				found = true;
				break;
			}
			char curC = strs[0][idx];
			for(size_t i=1;i<strs.size();i++)
			{
				if(idx>=strs[i].size())
				{
					found = true;
					break;
				}
				else if(strs[i][idx] != curC)
				{
					found = true;
					break;
				}
			}
			if(!found)
				idx++;
		}

		if(idx == 0)
			return "";
		else
			return strs[0].substr(0,idx);

    }
};

#endif